package com.jiajiankang.goods;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

import com.jiajiankang.R;
import com.jiajiankang.index.Main;
import com.jiajiankang.myspace.MyFavor;
import com.jiajiankang.shopcart.ShopCart;

public class Goods extends ThreeButton {
	private ImageButton ibtn_shopcart;
	private ImageButton ibtn_myfavor;
	EditText goods_number;
	ImageButton jiahao, jianhao;
	String a;
	int number;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.goods);
		myClickHandler();
		 goods_number = (EditText) findViewById(R.id.goods_number);
		 goods_number.setText("1");
		 a = goods_number.getText().toString();
		number = Integer.parseInt(a, 10);
		jiahao=(ImageButton)findViewById(R.id.goods_numberadd);
		jiahao.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				goods_number.setText(""+(number+1));
				number++;
			}
		});
		jianhao=(ImageButton)findViewById(R.id.goods_numbersub);
		jianhao.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if(number<=1)
				{
					
				}
				else
				{
					goods_number.setText(""+(number-1));
					number--;
					
				}
			}
		});
		
		Button DeliveryEnd_back = (Button) findViewById(R.id.goods_back);
		DeliveryEnd_back.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(Goods.this, Main.class);
				startActivity(intent);
			}
		});
		ibtn_shopcart=(ImageButton)findViewById(R.id.goods_shoppingcart);
		ibtn_shopcart.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			Intent intent=new Intent(Goods.this,ShopCart.class);
			startActivity(intent);
			}
		});
		ibtn_myfavor=(ImageButton)findViewById(R.id.goods_collect);
		ibtn_myfavor.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			Intent intent=new Intent(Goods.this,MyFavor.class);
			startActivity(intent);
			}
		});

		myClickHandler();
		three_goods.setImageDrawable(getResources().getDrawable(R.drawable.three_btn1));
		three_goods.setBackgroundColor(Color.parseColor("#ffffff"));
	}

}
